package org.schrag.sbbdroid;

import org.schrag.sbbdroid.data.Connection;

import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

public class ConnectionWrapper {
	private TextView name = null;
	private TextView address = null;
	private ImageView icon = null;
	private View row = null;

	ConnectionWrapper(View row) {
		this.row = row;
	}

	void populateFrom(Connection c) {
		getName().setText(c.getFrom() + " -> " + c.getTo());
		getAddress().setText(c.getDuration() + " / " + c.getChangeTrack());
	}

	TextView getName() {
		if (name == null) {
			name = (TextView) row.findViewById(R.id.name);
		}
		return (name);
	}

	TextView getAddress() {
		if (address == null) {
			address = (TextView) row.findViewById(R.id.address);
		}
		return (address);
	}

	ImageView getIcon() {
		if (icon == null) {
			icon = (ImageView) row.findViewById(R.id.icon);
		}
		return (icon);
	}
}
